Socket
Socket
Sign inDemoInstall

reselect

Package Overview
Dependencies
Maintainers
7
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reselect

Selectors for Redux.


Version published
Maintainers
7
Created

What is reselect?

Reselect is a library for building memoized selectors in Redux. Selectors can compute derived data, allowing Redux to store the minimal possible state. Reselect selectors can be used to efficiently compute derived data from the Redux store.

What are reselect's main functionalities?

Memoization

Reselect provides memoization for selectors. Selectors created with `createSelector` only recompute when their inputs change, which saves on unnecessary recalculations.

const getVisibleTodos = createSelector(
  [getVisibilityFilter, getTodos],
  (visibilityFilter, todos) => {
    switch (visibilityFilter) {
      case 'SHOW_ALL':
        return todos;
      case 'SHOW_COMPLETED':
        return todos.filter(t => t.completed);
      case 'SHOW_ACTIVE':
        return todos.filter(t => !t.completed);
    }
  }
)

Composability

Selectors can be composed together. One selector can use the output of another selector as input, allowing for complex queries to be built up in a clean and maintainable way.

const getTodoList = state => state.todoList;
const getKeyword = state => state.keyword;
const getFilteredTodoList = createSelector(
  [getTodoList, getKeyword],
  (todoList, keyword) => todoList.filter(todo => todo.includes(keyword))
);

Performance Optimization

Reselect helps in optimizing performance by avoiding unnecessary computations. This is particularly useful when dealing with expensive operations that should not be run every time the state updates.

const expensiveSelector = createSelector(
  state => state.items,
  items => expensiveComputation(items)
);

Other packages similar to reselect

Keywords

FAQs

Package last updated on 16 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc